﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Runtime.Serialization;

namespace ViCode_LeVi.Langs
{
    public enum Enum_Lang : int
    {
        VI = 1,
        EN = 2
    }
    [DataContract]
    public class LangManager : INotifyPropertyChanged
    {
        public static void Run()
        {
        }
        static LangManager()
        {
            Intance = new LangManager() { Is_Lang_EN = true };
        }
        #region INotifyPropertyChanged Members
        public void SendPropertyChanged(string sProp)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(sProp));
        }
        public event PropertyChangedEventHandler PropertyChanged;

        #endregion

        #region Lang
        private Enum_Lang _Enum_Lang = Enum_Lang.VI;
        public bool Is_Lang_VI
        {
            get { return _Enum_Lang == Enum_Lang.VI; }
            set
            {
                if (value == true)
                {
                    _Enum_Lang = Enum_Lang.VI;
                    SetLang_VI();
                }
                CheckLang();
                SendPropertyChanged("Is_Lang_VI");
                SendPropertyChanged("Is_Lang_EN");
            }
        }
        public bool Is_Lang_EN
        {
            get { return _Enum_Lang == Enum_Lang.EN; }
            set
            {
                if (value == true)
                {
                    _Enum_Lang = Enum_Lang.EN;
                    SetLang_EN();
                }
                CheckLang();
                SendPropertyChanged("Is_Lang_VI");
                SendPropertyChanged("Is_Lang_EN");
            }
        }
        #endregion

        public const string PATH_LANG_VIETNAMESE = "lang.vi";
        public const string PATH_LANG_ENGLISH = "lang.en";

        public static LangManager Intance { get; set; }

        private static void CheckLang()
        {
        }
        public static void SetLang_VI()
        {
            //Doc file
            string sPath = System.IO.Path.Combine(FileFolder.AppInfo.AppDirectory, "Langs/" + PATH_LANG_VIETNAMESE);
            var lang = XMLDataSerializer.XMLData<ControlTextInfo>.GetEntity(sPath);
            //Set efault neu NULL
            if (lang == null)
                lang = CreateDefault_VI();
            //Change UI
            ControlTextInfo.Intance = lang;
        }
        public static void SetLang_EN()
        {
            //Doc file
            string sPath = System.IO.Path.Combine(FileFolder.AppInfo.AppDirectory, "Langs/" + PATH_LANG_ENGLISH);
            var lang = XMLDataSerializer.XMLData<ControlTextInfo>.GetEntity(sPath);
            //Set efault neu NULL
            if (lang == null)
                lang = CreateDefault_EN();
            //Change UI
            ControlTextInfo.Intance = lang;
        }

        public static ControlTextInfo CreateDefault_VI()
        {
            var _Intance = new ControlTextInfo()
            {
                Application_Title = "SwissCreate Business Plan Writer",
                Measure_Alert_Title = "SwissCreate Alert Measure",
                Menu_Project = "Dự án",
                Menu_Project_CreateNew = "Tạo mới",
                Menu_Project_Open = "Mở file",
                Menu_Project_Save = "Lưu",
                Menu_Project_SaveAs = "Lưu file khác",
                Menu_Project_DesignMode = "Chỉnh sửa thông tin",
                Menu_Project_DesignRiskInfo = "Chỉnh sửa dữ liệu",
                Menu_Operation = "Các bước",
                Menu_Lang = "Ngôn ngữ",
                Menu_Lang_VI = "Tiếng Việt",
                Menu_Lang_EN = "EngLish",
                Dialog_File4Saving_Title = "Chọn đường dẫn file để lưu.",
                Group_StepResult_Header = "Đánh giá kết quả",
                TextBlock_Filter_Task_Text = "Lọc theo",
                Button_Content_Detail = "Chi tiết",
                ComboBox_ItemAll_Text = "Tất cả",
                TaskItem_ID_Text = "Mã",
                TaskItem_Name_Text = "Tên",
                TaskItem_IsActive_Text = "Hoạt động",
                TaskItem_Define_Text = "Mô tả",
                TaskItem_WeightText = "Mức độ",
                TaskItem_WeightReasonText = "Diễn dãi",
                TaskItem_Quantity_Text = "Số lượng",
                TaskItem_Quanlity_Text = "Chất lượng",
                TaskItem_Systematic_Text = "Hệ thống",
                TaskItem_Question_Text = "Câu hỏi",
                TaskItem_Anwser_Text = "Trả lời",
                TaskItem_ISTWeight_Percent_Text = "Mức độ %",
                TaskItem_Evaluation_Text = "Trạng thái",
                TaskItem_Control_Detail_Text = "Chi tiết",
                Button_Content_OK = "Xong",
                Button_Content_Cancel = "Bỏ qua",
                Measurement_Title_Text = "Tiêu đề",
                Measurement_Expenses_Text = "Chi phí đầu tư",
                Measurement_ExpertedBenefits_Text = "Lợi ích dự kiến",
                Measurement_GoalOutCome_Text = "Mục đích",
                Measurement_Duration_Text = "Thời hạn (tháng)",
                Measurement_Procedure_Text = "Mô tả",
                Measurement_Start_Text = "Bắt đầu",
                Measurement_Status_Text = "Trạng thái",
                RiskManagementItem_Impact_Text = "Impact",
                RiskManagementItem_Probability_Text = "Xác suất",
                RiskManagementItem_Manage_Text = "Manage",
                RiskManagementItem_Risk_Text = "Risk",
                RiskManagementItem_RiskNo_Text = "Mã"
            };
            return _Intance;
        }
        public static ControlTextInfo CreateDefault_EN()
        {
            var _Intance = new ControlTextInfo()
            {
                Application_Title = "SwissCreate Business Plan Writer",
                Measure_Alert_Title = "SwissCreate Alert Measure",
                Menu_Project = "Project",
                Menu_Project_CreateNew = "New",
                Menu_Project_Open = "Open",
                Menu_Project_Save = "Save",
                Menu_Project_SaveAs = "Save as",
                Menu_Project_DesignMode = "Modify Info",
                Menu_Project_DesignRiskInfo = "Modify Data Info",
                Menu_Project_ModifyProjectInfo = "Modify Project Info",
                Menu_Operation = "Job Steps",
                Menu_Lang = "Languague",
                Menu_Lang_VI = "Tiếng Việt",
                Menu_Lang_EN = "EngLish",
                Dialog_File4Saving_Title = "Choose path to save.",
                Group_StepResult_Header = "Comment",
                TextBlock_Filter_Task_Text = "Filter",
                Button_Content_Detail = "Detail",
                ComboBox_ItemAll_Text = "All",
                TaskItem_ID_Text = "ID",
                TaskItem_Name_Text = "Title",
                TaskItem_IsActive_Text = "Active",
                TaskItem_Define_Text = "Defination",
                TaskItem_WeightText = "Weight",
                TaskItem_WeightReasonText = "Reason of Weight",
                TaskItem_Quantity_Text = "Quantity(in %)",
                TaskItem_Quanlity_Text = "Quanlity(in %)",
                TaskItem_Systematic_Text = "Systematic(in %)",
                TaskItem_Question_Text = "Question",
                TaskItem_Anwser_Text = "Answer",
                TaskItem_ISTWeight_Percent_Text = "IST Weight %",
                TaskItem_Evaluation_Text = "Evaluation",
                TaskItem_Control_Detail_Text = "Detail",
                Button_Content_OK = "OK",
                Button_Content_Cancel = "Cancel",
                Measurement_Title_Text = "Title",
                Measurement_Expenses_Text = "Expenses\nInvestment volume",
                Measurement_ExpertedBenefits_Text = "Expected benefits",
                Measurement_GoalOutCome_Text = "Goal / outcome",
                Measurement_Duration_Text = "Duration",
                Measurement_Procedure_Text = "Procedure",
                Measurement_Start_Text = "Start",
                Measurement_Status_Text = "Status",
                RiskManagementItem_Impact_Text = "Impact",
                RiskManagementItem_Probability_Text = "Probability",
                RiskManagementItem_Manage_Text = "Manage",
                RiskManagementItem_Risk_Text = "Risk",
                RiskManagementItem_RiskNo_Text = "No"
            };
            return _Intance;
        }
    }

}
